#include<iostream>
using namespace std;

class Solution {
public:

    inline int trans(string& s, int start) { // 将一个两位的字符串数字转化为 int
        return (s[start] - '0') * 10 + s[start + 1] - '0';
    }

    bool early(string& a, string& b) {
        if (trans(a, 0) < trans(b, 0)) {
            return true;
        }else if (trans(a, 0) == trans(b, 0)) {
            return trans(a, 3) < trans(b, 3);
        }
        return false;
    }
    int countDaysTogether(string arriveAlice, string leaveAlice, string arriveBob, string leaveBob) {
        int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        if (early(leaveAlice, arriveBob) || early(leaveBob, arriveAlice)) {
            return 0;
        }
        string first, second;
        if (early(arriveAlice, arriveBob)) {
            first = arriveBob;
        } else {
            first = arriveAlice;
        }
        if (early(leaveAlice, leaveBob)) {
            second = leaveAlice;
        } else {
            second = leaveBob;
        }
        cout << first << endl;
        cout << second << endl;

        if (trans(first, 0) == trans(second, 0)){         // 月份相等
            return trans(second, 3) - trans(first, 3) + 1;
        } else {
            int ans = 0;
            for (int i = trans(first, 0) + 1; i < trans(second, 0); i++) {
                ans += days[i - 1];
            }
            ans += days[trans(first, 0) - 1] - trans(first, 3) + 1;
            ans += trans(second, 3);
            return ans;
        }
        return 0;
    }
};